package opc.read.utils;

import com.alibaba.fastjson.JSON;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedHashMap;

/**
 * @Description:  仙鹤的json信号文件
 * @author: liyuan
 * @data 2021-01-07 17:47
 */
public class ReadJSONItem {

    public static LinkedHashMap xianHe() throws IOException {
        InputStream is = ReadJSONItem.class.getClassLoader().getResourceAsStream("json_xianhe_13.json");
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
        String s = null;
        StringBuilder builder = new StringBuilder();
        while ((s = bufferedReader.readLine()) != null) {
            String s1 = s.split("\\//")[0];
            builder.append(s1);
        }
        //输入输出的信号
        LinkedHashMap<String, Object> linkedHashMap = JSON.parseObject(builder.toString(), LinkedHashMap.class);
        //关闭流
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (is != null) {
            try {
                is.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return linkedHashMap;
    }
}
